<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript">
        var fun=new Function("num1","num2","num3","return num1+num2;");//影响性能，两次解析
        console.log(fun(2,4,3));


        function sum(num1,num2){
            return num1+num2;
        }
        function box(sum,num3){
           return sum+num3;
        }
        console.log(box(sum(10,20),30))//作为值的传递

        function arg(num1,num2){
            console.log(arguments[1]);//获取第二个参数
        }
        arg(10,20);
        //递归
        function sum(num){
            if(num<=1){
                return 1;
            }else{
                return num*arguments.callee(num-1);//动态的调用自己本方法
            }
        }
        console.log(sum(3));

        window.color="红色";
        console.log(this.color);
        console.log(color);
        var a={color:'黑色'};
        console.log(this.a.color);
        function sumNum(num1,num2){
            return num1+num2;
        }
        console.log(sumNum.length);//返回参数个数

        function say(num1,num2){
            //两种冒充调用方法
            sumNum.apply(this,arguments);
            return sumNum.call(this,num1,num2);
        }
        console.log(say(10,30));

    </script>

</head>
<body>

</body>
</html>